package com.blqy.fr.template.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blqy.fr.model.template.Template;
import com.blqy.fr.vo.template.TemplateVo;
import com.blqy.fr.vo.template.ChildTagItemVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;

@Mapper
public interface TemplateInfoMapper extends BaseMapper<Template> {

    List<TemplateVo> getTemplateInfo(@Param("templateName") String templateName);

    List<ChildTagItemVo> selectTemplateStructure(@Param("templateName") String templateName);

    @Select("SELECT COUNT(1) > 0 FROM template WHERE template_name = #{name} AND is_deleted = 0")
    boolean existsByName(@Param("name") String name);

    @Select("UPDATE template SET update_time = NOW() WHERE id = #{templateId}")
    void updateTemplateTime(@Param("templateId") Long templateId);
}
